

import com.lizy.entity.User;
import com.lizy.service.UserService;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;

import java.util.Arrays;

/**
 * @Author: lizy
 * @CreateTime: 2024-10-15
 * @Description:
 * @Version: 1.0
 */
public class Main {
	public static void main(String[] args) {
		DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
		XmlBeanDefinitionReader xmlBeanDefinitionReader = new XmlBeanDefinitionReader(beanFactory);
		xmlBeanDefinitionReader.loadBeanDefinitions("classpath:./bean.xml");
		String[] beanDefinitionNames = beanFactory.getBeanDefinitionNames();
		System.out.println(Arrays.asList(beanDefinitionNames));
		UserService userService = (UserService) beanFactory.getBean("userService");
		 User user = userService.findById(1L);
		System.out.println(user);
	}
}
